package connection;

import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooKeeper;

import java.io.IOException;

/**
 * @author: Lixy
 * @email: 1908598362@qq.com
 * @date: 2022/2/21 星期一 11:27
 */
public class zkConnection {
    //zk的地址 格式为ip：port
    private String zkServer;

    private int sessionTimeout;

    public zkConnection(){
        super();
        this.zkServer="localhost:2181";
        this.sessionTimeout=50000;
    }

    public zkConnection(String zkServer,int sessionTimeout){
        this.zkServer=zkServer;
        this.sessionTimeout=sessionTimeout;
    }

    public ZooKeeper getConn() throws IOException {
        return new ZooKeeper(zkServer, sessionTimeout, new Watcher() {
            @Override
            public void process(WatchedEvent watchedEvent) {

            }
        });
    }
}
